package jupiter.util;

//import java.sql.*;


import javax.naming.InitialContext;
import javax.naming.NamingException;
import javax.sql.DataSource;

import jupiter.messaging.Message;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class DBConnection {
	static Logger logger = LoggerFactory.getLogger(DBConnection.class);
	private static DataSource getDataSource(){
		InitialContext ictx = null;
		try {
			ictx = new InitialContext();
		} catch (NamingException e) {
			logger.error("NamingException", e);
		}
		DataSource ds = null;
		try {
			ds = (DataSource) ictx.lookup( "java:comp/env/jdbc/db" );
		} catch (NamingException e) {
			logger.error("NamingException", e);
		}
		return ds;
	}

	public static DataSource ds = DBConnection.getDataSource();
    
}
